"""
加上 _ 或 __ 前缀 代表私有
但是python并没有强制的限制符
防君子不防小人

有一个类A，它有私有属性_name
a = A()
一个_: a._name可以直接取出来
两个__: a._A__name可以取出来   _类名__属性

"""

class A:
    def __init__(self, name, sex):
        self._name = name
        self.__sex = sex

    def _say_hello(self, msg: str):
        print("_: ", msg)

    def __say_hello2(self, msg: str):
        print("__: ", msg)


class B(A):
    def __init__(self, name, sex, real_name):
        # super(B, self).__init__(name, sex)  # 显式指定
        super().__init__(name, sex)  # 隐式绑定
        self.real_name = real_name


a = A("lihua", "man")
print(a._name)
print(a._A__sex)
a._say_hello("ddd")
a._A__say_hello2("xxx")

b = B("hhh", "woman", "zxp")
print(b._name)
print(b._A__sex)
b._say_hello("ddd")
print(b.real_name)
